import com.alibaba.nacos.api.naming.NamingFactory;
import com.alibaba.nacos.api.naming.NamingService;
import com.alibaba.nacos.api.naming.pojo.Instance;

import java.util.Properties;

/**
 * 服务注册
 */
public class TestNacosAPI {
    public static void main(String[] args) throws Exception {
        String serverAddr = "127.0.0.1";
        Properties properties = new Properties();
        properties.put("serverAddr", serverAddr);
        NamingService namingService = NamingFactory.createNamingService(properties);

        // 模拟需要在服务中心注册的服务
        Instance instance = new Instance();
        instance.setIp("127.0.0.1");
        instance.setPort(8888);
        namingService.registerInstance("userService", instance);
        System.in.read();
    }
}
